<?php              
define('DEFAULT_TABLE_ROWS', 1);

$var_cui_furnizor = 0;
$var_id_program = 0;
$var_id_sesiune = 0;

if($_SERVER['REQUEST_METHOD'] == "POST" and isset($_POST['cui_furnizor']) and isset($_POST['id_program']))
{
	$var_cui_furnizor = $_POST['cui_furnizor'];
	$var_id_program = $_POST['id_program'];
}
else  if($_SERVER['REQUEST_METHOD'] == "GET" and isset($_GET['cui_furnizor']) and isset($_GET['id_program']))
{
	$var_cui_furnizor = $_GET['cui_furnizor'];
	$var_id_program = $_GET['id_program'];
}


if($_SERVER['REQUEST_METHOD'] == "POST" and isset($_POST['id_program']))
{
	$var_id_program = $_POST['id_program'];
}
else if($_SERVER['REQUEST_METHOD'] == "GET" and isset($_GET['id_program']))
{
	$var_id_program = $_GET['id_program'];
}

if($_SERVER['REQUEST_METHOD'] == "POST" and isset($_POST['id_sesiune']))
{
	$var_id_sesiune = $_POST['id_sesiune'];
}
else if($_SERVER['REQUEST_METHOD'] == "GET" and isset($_GET['id_sesiune']))
{
	$var_id_sesiune = $_GET['id_sesiune'];
}

include "functions".DIRECTORY_SEPARATOR."utils.php";
include "includes".DIRECTORY_SEPARATOR."include_user_sessions_forms_for_tables.php";
							
$form_fields_with_speficications = array();

for($index = 1; $index <= DEFAULT_TABLE_ROWS; $index+=1) 
{
	foreach( $form_for_table as $form_column_table )
	{
		array_push( $form_fields_with_speficications,$form_column_table);
	}
}

foreach($form_fields_with_speficications as $form_key => $form_value)
{
	if( ! isset($form_fields_with_speficications[$form_key]['colors']) )
			$form_fields_with_speficications[$form_key]['colors'] = array('first' => '#333333', 'second' => 'red');

	if( ! isset($form_fields_with_speficications[$form_key]['field_size']) )
			$form_fields_with_speficications[$form_key]['field_size'] = null;
	if( ! isset($form_fields_with_speficications[$form_key]['max_length']) )
			$form_fields_with_speficications[$form_key]['max_length'] = null;
	if( ! isset($form_fields_with_speficications[$form_key]['regex']) )
			$form_fields_with_speficications[$form_key]['colors'] = null;						  
	if( ! isset($form_fields_with_speficications[$form_key]['can_be_null']) )
			$form_fields_with_speficications[$form_key]['can_be_null'] =  false;
	
	if( ! isset($form_fields_with_speficications[$form_key]['current_value']))
	{
		if( $form_fields_with_speficications[$form_key]['field_type'] == 'text')
		{
			if( isset($form_fields_with_speficications[$form_key]['initial_values']) )
				$form_fields_with_speficications[$form_key]['current_value'] = $form_fields_with_speficications[$form_key]['initial_values'];
			else
				$form_fields_with_speficications[$form_key]['current_value'] =  '';
		}
		else if( $form_fields_with_speficications[$form_key]['field_type'] == 'drop_down_list')
		{
			$form_fields_with_speficications[$form_key]['current_value'] = "neselectat";
		}
	}
	
	$form_fields_with_speficications[$form_key]['current_color'] = $form_fields_with_speficications[$form_key]['colors']['first'];	
}

$form_content = generate_form_content($form_fields_with_speficications, 1);


$get_form=<<<GATA
	<form method="post" action = "public_search.php">
		<table border="0" width="100%" cellspacing="3" cellpadding="3" align="center">
			$form_content
			<input type="hidden" name="view_sesiune" value="true">
			<input type="hidden" name="cui_furnizor" value="$var_cui_furnizor"> 
			<input type="hidden" name="id_program" value="$var_id_program"> 
			<input type="hidden" name="id_sesiune" value="$var_id_sesiune"> 
		</table>
	</form>
GATA;


if($_SERVER['REQUEST_METHOD'] == 'GET')
{
	echo $get_form;
}
				
?> 